//
//  FlyView.m
//  Fly
//
//  Created by dllo on 15/12/1.
//  Copyright (c) 2015年 zwb. All rights reserved.
//

#import "FlyView.h"
#import "XYZPhoto.h"
@implementation FlyView
{
    UIView *_view;
}
- (instancetype)initWithFrame:(CGRect)frame {
    if (self = [super initWithFrame:frame]) {
       
    }
    return self;
    
}

- (instancetype)init {
    if (self = [super init]) {
       
    }
    return self;
}

- (instancetype)initWithFrame:(CGRect)frame withImageArr:(NSArray *)imageArr {
    if (self = [super initWithFrame:frame]) {
      
        if (imageArr.count) {
            for (int i = 0; i < imageArr.count; i++) {
                float X = (arc4random()% 100);
                float Y = arc4random()%100;
                float W = ((arc4random() % 100) + 100);
                float H = ((arc4random() % 100) + 100);
                XYZPhoto *photo = [[XYZPhoto alloc] initWithFrame:CGRectMake(X, Y, W, H)];
                photo.backgroundColor = [UIColor redColor];
//                [photo updateImage:[UIImage imageWithContentsOfFile:imageArr[i]]];
                [photo hahahImage:imageArr[i]];
                [self addSubview:photo];
                 float alpha = i*1.0/(imageArr.count + 1) + 0.2;
                [photo setImageAlphaAndSpeedAndSize:alpha];
            }
        }
    }
    return self;
}


- (instancetype)initWithFrame:(CGRect)frame WithImage:(CGImageRef)image WithCount:(NSInteger)count {
    
    if (self = [super initWithFrame:frame]) {
        
        if (count) {
            
//            for (int i = 0; i < count; i++) {
                float X = (arc4random()% 100);
                float Y = arc4random()%100;
                float W = ((arc4random() % 100) + 50);
                float H = ((arc4random() % 100) + 50);
                XYZPhoto *photo = [[XYZPhoto alloc] initWithFrame:CGRectMake(X, Y, W, H)];
                photo.backgroundColor = [UIColor redColor];
//                [photo updateImage:[UIImage imageWithContentsOfFile:i[i]]];
                photo.imageView.image= [UIImage imageWithCGImage:image];
//                [photo addmyImage:image];
                [self addSubview:photo];
                float alpha = 1.0/(count + 1) + 0.2;
            
                [photo setImageAlphaAndSpeedAndSize:alpha];
//            }

            
            
        }
        
        
        
        
        
    }
    return self;
}




@end
